#define DELTA 0.001

#include <cmath>
#include "util/MathUtils.h"

namespace util {

bool doubleEquals(double x, double y) {
	return doubleEquals(x, y, DELTA);
}

bool doubleEquals(double x, double y, double delta) {
	return fabs(x - y) < delta;
}

bool doubleLess(double x, double y, bool orEquals) {
	if (doubleEquals(x, y)) {
		return orEquals;
	}
	return (x < y);
}

bool doubleGreater(double x, double y, bool orEquals) {
	if (doubleEquals(x, y)) {
		return orEquals;
	}
	return (x > y);
}
bool doubleIsBetween(double d, double x, double y, bool orEquals) {
	return (doubleGreater(d, x, orEquals) && doubleLess(d, y, orEquals));
}

int doubleToInt(double d) {
	return doubleLess((d - (int) d), 0.5, false) ? (int) floor(d) : (int) ceil(d);

}

}
